package com.heima.minio;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import io.minio.errors.*;
import org.mockito.internal.matchers.Null;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class MinioDemo {
	public static void main(String[] args) {
		FileInputStream fileInputStream = null;
		try {
			fileInputStream = new FileInputStream("D:\\index.html");
			//1.创建minio链接客户端
			MinioClient minioClient = MinioClient.builder().credentials("minio", "minio123")
					.endpoint("http://192.168.200.104:9000").build();
			//2.上传
			PutObjectArgs putObjectArgs = PutObjectArgs.builder()
					.object("list.html")//文件名
					.contentType("text/html")//文件类型
					.bucket("leadnews")//桶名字
					.stream(fileInputStream, fileInputStream.available(), -1)
					.build();
			minioClient.putObject(putObjectArgs);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
